package com.zshan.clinic.web.controller;


import com.zshan.clinic.web.entity.UserInfo;
import com.zshan.clinic.web.service.ExportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;


/**
 * 导出
 * @author lichen
 */
@RestController
@RequestMapping("/export")
public class ExportController extends AbstractController{


    @Autowired
    private ExportService exportService;


    /**
     * 导出挂号列表
     * @param patientName 患者名
     * @param deptId 部门
     * @param visitDate 就诊日期
     * @param regStatus 就诊状态 regStatusEnum
     * @return
     */
    @GetMapping("/exportRegister")
    public void exportRegister(HttpServletResponse response,
                                @RequestParam(name = "patientName", required = false) String patientName,
                                @RequestParam(name = "deptId", required = false) Long deptId,
                                @RequestParam(name = "doctorId", required = false) Long doctorId,
                                @RequestParam(name = "visitDate") LocalDate visitDate,
                                @RequestParam(name = "regStatus", required = false) String regStatus) {
        UserInfo userInfo = getUserInfo();
        exportService.exportRegister(response,userInfo.getClinicId(),patientName, deptId,doctorId,visitDate,regStatus);
    }


    /**
     * 导出采购单
     * @param response
     * @param orderNo
     * @param orderStatus
     * @param settleStatus
     * @param storageId
     */
    @GetMapping("/exportOrderPurchase")
    public void exportOrderPurchase(HttpServletResponse response,
                                    @RequestParam(name = "orderNo", required = false) String orderNo,
                                    @RequestParam(name = "orderStatus", required = false) String orderStatus,
                                    @RequestParam(name = "settleStatus", required = false) String settleStatus,
                                    @RequestParam(name = "storageId", required = false) Long storageId) {
        UserInfo userInfo = getUserInfo();
        exportService.exportOrderPurchase(response,userInfo.getClinicId(),orderNo, orderStatus,settleStatus,storageId);
    }


}
